import Vue from "vue";
import VueRouter, { RouteConfig } from "vue-router";
import chunk from "./pathApi";
import Layout from "@/layout/index.vue";
import rouetrAdd from "@/router/pageOptions";

Vue.use(VueRouter);

const routes: Array<RouteConfig> = [
  {
    path: "/",
    component: Layout,
    redirect: "/login",
    children: rouetrAdd,
  },
  {
    path: "/login",
    component: () => import("@pages/login/Login.vue"),
    name: "login",
    meta: {
      auth: false,
      title: "欢迎登录同策网工作台",
    },
  },
  {
    path: "*",
    redirect: "home/statistics",
    meta: {
      title: "404",
    },
  },
];

const router = new VueRouter({
  mode: "history",
  routes,
  // scrollBehavior(to, from, savedPosition) { //路由跳转前是否有滚动，回退按钮回来时是否定位到滚动页面
  //   if (savedPosition) {
  //     return savedPosition
  //   } else {
  //     return {
  //       x: 0,
  //       y: 0
  //     }
  //   }
  // },
});

export default router;
